﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for BestilingJod.xaml
    /// </summary>
    public partial class Jod : Window
    {
        public Jod()
        {
            InitializeComponent();
        }

        private void bestilJodButton_Click(object sender, RoutedEventArgs e)
        {
            //code til bestilling af jod

            TextBox[] ctrls = { jodTextbox1, jodTextbox2, jodTextbox3, jodTextbox4, jodTextbox5, jodTextbox6, jodTextbox7, jodTextbox8, jodTextbox9, jodTextbox10, jodTextbox11, jodTextbox12, jodTextbox13, jodTextbox14, jodTextbox15 };
            Microsoft.Office.Interop.Word.Bookmark[] jod = new Microsoft.Office.Interop.Word.Bookmark[15];
            String file = @"K:/Ansattes mapper/Thomas/Data/FAX order form GE Healthcare.doc";
            String dato = calendar1.SelectedDate.ToString();
            String OrdreNr = ordreNrtextBox.Text;
            String BestiltAf = "Thomas Schmidt";
            //String BestiltAf = bestiltAfcomboBox.SelectedValue.ToString();
            String antal;
            String[] antalA = new string[15];
            Int32[] dosis = { 74, 148, 185, 222, 259, 296, 333, 370, 407, 444, 481, 518, 555, 592, 629 };
            String[] jodBookmark = { "jod1", "jod2", "jod3", "jod4", "jod5", "jod6", "jod7", "jod8", "jod9", "jod10", "jod11", "jod12", "jod13", "jod14", "jod15" };
            String[] datoBookmark = { "dato1", "dato2", "dato3", "dato4", "dato5", "dato6", "dato7", "dato8", "dato9", "dato10", "dato11", "dato12", "dato13", "dato14", "dato15", };

            // Foreach løkke der løber igennem alle tekstbokse og tjekker om der er skrevet en værdi deri
            int i = 0;
            foreach(TextBox ctrl in ctrls)
            {
                
                antal = ctrl.Text;
                //Bestilling_new.editWordDocument(file, jodBookmark[i], datoBookmark[i], OrdreNr, antal, dato, BestiltAf);
                if (ctrl.Text == "" || ctrl.Text == "0" || ctrl.Text.Length == 0)
                {
                    //Code til at tjekke
                    MessageBox.Show("Ingen jod" + i);
                    //jodBookmark[i] = ctrl.Text;
                    
                }
                else 
                {
                    //Indsæt kode her er indsætte bestilling i word-dukoment
                    antalA[i] = ctrl.Text;
                    MessageBox.Show("Bestil " + ctrl.Text + " " + dosis[i]);


                    //Bestilling_new.editWordDocument(@"K:/Ansattes mapper/Thomas/Data/FAX order form GE Healthcare.doc", 555555, antal,  ;

                }
                i++;
            }
        }
    }
}
